package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Business;
import cn.wolfcode.mapper.BusinessMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IBusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessServiceImpl implements IBusinessService {
    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public int insertBusiness(Business record) {
        businessMapper.insert(record);
        return 0;
    }

    @Override
    public int deleteBusiness(Long id) {
        businessMapper.deleteByPrimaryKey(id);
        return 0;
    }

    @Override
    public int updateBusiness(Business record) {
        return businessMapper.updateByPrimaryKey(record);
    }

    @Override
    public Business selectBusiness(Long id) {
        return businessMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Business> selectBusinessList() {
        return businessMapper.selectAll();
    }



    @Override
    public PageInfo<Business> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<Business>(businessMapper.queryList(qo));
    }

    @Override
    public Business selectMainStore() {
        return businessMapper.selectMainStore();
    }
}
